home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-12-08 | 2.6 KB | 97 lines |
- /*
- A basic extension of the java.awt.Dialog class
- */
-
- import java.awt.*;
-
- public class FindDialog extends Dialog {
- void cancelButton_Clicked(Event event) {
- // to do: place event handler code here.
- hide();
- dispose();
- }
-
- void findButton_Clicked(Event event) {
- // to do: place event handler code here.
- hide();
- dispose();
- }
-
- public boolean matchCase()
- {
- return m_MatchCase.getState();
- }
- public String getFindString()
- {
- return findText.getText();
- }
-
- public FindDialog(Frame parent, boolean modal) {
-
- super(parent, modal);
-
- //{{INIT_CONTROLS
- setLayout(null);
- addNotify();
- resize(insets().left + insets().right + 358,insets().top + insets().bottom + 98);
- setBackground(new Color(12632256));
- findText = new java.awt.TextField();
- findText.reshape(insets().left + 80,insets().top + 20,190,20);
- add(findText);
- findButton = new java.awt.Button("Find");
- findButton.reshape(insets().left + 280,insets().top + 10,70,20);
- add(findButton);
- cancelButton = new java.awt.Button("Cancel");
- cancelButton.reshape(insets().left + 280,insets().top + 40,70,20);
- cancelButton.setFont(new Font("Dialog", Font.BOLD, 10));
- add(cancelButton);
- label2 = new java.awt.Label("Find What");
- label2.reshape(insets().left + 0,insets().top + 10,80,16);
- add(label2);
- m_MatchCase = new java.awt.Checkbox("Match case");
- m_MatchCase.reshape(insets().left + 10,insets().top + 60,100,20);
- m_MatchCase.setBackground(new Color(12632256));
- add(m_MatchCase);
- setTitle("Dialog1");
- //}}
- }
-
- public FindDialog(JavaPad parent, String title, boolean modal, String findString) {
- this(parent, modal);
- setTitle(title);
- findText.setText(findString);
- }
-
- public synchronized void show() {
- Rectangle bounds = getParent().bounds();
- Rectangle abounds = bounds();
-
- move(bounds.x + (bounds.width - abounds.width)/ 2,
- bounds.y + (bounds.height - abounds.height)/2);
-
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if(event.id == Event.WINDOW_DESTROY) {
- hide();
- return true;
- }
- if (event.target == findButton && event.id == Event.ACTION_EVENT) {
- findButton_Clicked(event);
- }
- if (event.target == cancelButton && event.id == Event.ACTION_EVENT) {
- cancelButton_Clicked(event);
- }
- return super.handleEvent(event);
- }
-
- //{{DECLARE_CONTROLS
- java.awt.TextField findText;
- java.awt.Button findButton;
- java.awt.Button cancelButton;
- java.awt.Label label2;
- java.awt.Checkbox m_MatchCase;
- //}}
- }
-